﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RAD.LightOne
{
    #region Documentation
    ///<summary>
    /// Classe que tem a função de transportar métodos estaticos para uma instância, a fim de facilitar o trabalho com ObjectDataSources.
    ///</summary>
    #endregion
    [DataObject]
    public class MyDataObject<T>: MyObject<T> where T:MyObject
    {
        [DataObjectMethod(DataObjectMethodType.Select,true)]
        public T[] FindAll()
        {
            return MyObject<T>.FindAll();
        }
        [DataObjectMethod(DataObjectMethodType.Select)]
        public T FindById(Guid id)
        {
            return MyObject<T>.FindById(id);
        }
        [DataObjectMethod(DataObjectMethodType.Select)]
        public T[] FindById(Guid[] ids)
        {
            return MyObject<T>.FindById(ids);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public void Delete(Guid id)
        {
            T obj = MyObject<T>.FindById(id);
            if (obj != null)
            {
                obj.Delete_();
            }
        }
    }
}
